package com.zzl.zzloj.model.enums;

import io.swagger.models.auth.In;
import org.apache.commons.lang3.ObjectUtils;
import org.checkerframework.checker.units.qual.A;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum QuestionSubmitStatusEnum {

    WAITING("待判题",0),
    PENDING("判题中",1),
    SUCCESS("判题成功",2),
    FAILED("判题失败",3);

    private final String text;
    private final Integer value;
    QuestionSubmitStatusEnum(String text,Integer value){
        this.text = text;
        this.value = value;
    }

    /**
     * 获取值列表
     * @return
     */
    public static List<Integer> getValues(){
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    /**
     * 根据值获取enum类
     * @param value
     * @return
     */
    public static QuestionSubmitStatusEnum getEnumByValue(Integer value){
        if(ObjectUtils.isEmpty(value)){
            return null;
        }
        for (QuestionSubmitStatusEnum statusEnum:QuestionSubmitStatusEnum.values()){
            if(statusEnum.value.equals(value)){
                return statusEnum;
            }
        }
        return null;
    }

    public String getText() {
        return text;
    }

    public Integer getValue() {
        return value;
    }
}
